//
// Navbars
// --------------------------------------------------
// Wrapper and base class
//
// Provide a static navbar from which we expand to create full-width, fixed, and
// other navbar variations.

.navbar {
  position: relative;
  min-height: @navbar-height; // Ensure a navbar always shows (e.g., without a .navbar-brand in collapsed mode)
  margin-bottom: @navbar-margin-bottom;
  border: 1px solid transparent;
  // Prevent floats from breaking the navbar
  &:extend(.clearfix all);

  @media (min-width: @grid-float-breakpoint) {
    border-radius: @navbar-border-radius;
  }
}

// Navbar heading
//
// Groups `.navbar-brand` and `.navbar-toggle` into a single component for easy
// styling of responsive aspects.

.navbar-header {
  &:extend(.clearfix all);

  @media (min-width: @grid-float-breakpoint) {
    float: left;
  }
}

// Navbar collapse (body)
//
// Group your navbar content into this for easy collapsing and expanding across
// various device sizes. By default, this content is collapsed when <768px, but
// will expand past that for a horizontal display.
//
// To start (on mobile devices) the navbar links, forms, and buttons are stacked
// vertically and include a `max-height` to overflow in case you have too much
// content for the user's viewport.

.navbar-collapse {
  overflow-x: visible;
  padding-right: @navbar-padding-horizontal;
  padding-left: @navbar-padding-horizontal;
  border-top: 1px solid transparent;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .1);
  &:extend(.clearfix all);
  -webkit-overflow-scrolling: touch;

  &.in {
    overflow-y: auto;
  }

  @media (min-width: @grid-float-breakpoint) {
    width: auto;
    border-top: 0;
    box-shadow: none;

    &.collapse {
      display: block !important;
      height: auto !important;
      padding-bottom: 0; // Override default setting
      overflow: visible !important;
    }

    &.in {
      overflow-y: visible;
    }

    // Undo the collapse side padding for navbars with containers to ensure
    // alignment of right-aligned contents.
    .navbar-fixed-bottom &,
    .navbar-fixed-top &,
    .navbar-static-top & {
      padding-left: 0;
      padding-right: 0;
    }
  }
}

.navbar-fixed-bottom,
.navbar-fixed-top {
  .navbar-collapse {
    max-height: @navbar-collapse-max-height;

    @media (max-device-width: @screen-xs-min) and (orientation: landscape) {
      max-height: 200px;
    }
  }
}

// Both navbar header and collapse
//
// When a container is present, change the behavior of the header and collapse.

.container,
.container-fluid {

  >.navbar-header,
  >.navbar-collapse {
    margin-right: -@navbar-padding-horizontal;
    margin-left: -@navbar-padding-horizontal;

    @media (min-width: @grid-float-breakpoint) {
      margin-right: 0;
      margin-left: 0;
    }
  }
}

//
// Navbar alignment options
//
// Display the navbar across the entirety of the page or fixed it to the top or
// bottom of the page.
// Static top (unfixed, but 100% wide) navbar

.navbar-static-top {
  z-index: @zindex-navbar;
  border-width: 0 0 1px;

  @media (min-width: @grid-float-breakpoint) {
    border-radius: 0;
  }
}

// Fix the top/bottom navbars when screen real estate supports it

.navbar-fixed-bottom,
.navbar-fixed-top {
  position: fixed;
  right: 0;
  left: 0;
  z-index: @zindex-navbar-fixed;

  // Undo the rounded corners
  @media (min-width: @grid-float-breakpoint) {
    border-radius: 0;
  }
}

.navbar-fixed-top {
  top: 0;
  border: 0;
  box-shadow: 0 0 2px #777;
}

.navbar-fixed-bottom {
  bottom: 0;
  margin-bottom: 0; // override .navbar defaults
  border-width: 1px 0 0;
}

// Brand/project name

.navbar-brand {
  float: left;
  padding: @navbar-padding-vertical @navbar-padding-horizontal;
  font-size: @font-size-large;
  line-height: @line-height-computed;
  height: @navbar-height;

  &:focus,
  &:hover {
    text-decoration: none;
  }

  >img {
    display: block;
  }

  @media (min-width: @grid-float-breakpoint) {

    .navbar>.container &,
    .navbar>.container-fluid & {
      margin-left: -@navbar-padding-horizontal;
    }
  }
}

// Navbar toggle
//
// Custom button for toggling the `.navbar-collapse`, powered by the collapse
// JavaScript plugin.

.navbar-toggle {
  position: relative;
  float: right;
  margin-right: @navbar-padding-horizontal;
  padding: 9px 10px;
  .navbar-vertical-align(34px);
  background-color: transparent;
  background-image: none; // Reset unusual Firefox-on-Android default style; see https://github.com/necolas/normalize.css/issues/214
  border: 1px solid transparent;
  border-radius: @border-radius-base;

  // We remove the `outline` here, but later compensate by attaching `:hover`
  // styles to `:focus`.
  &:focus {
    outline: 0;
  }

  // Bars
  .icon-bar {
    display: block;
    width: 22px;
    height: 2px;
    border-radius: 1px;
  }

  .icon-bar+.icon-bar {
    margin-top: 4px;
  }

  @media (min-width: @grid-float-breakpoint) {
    display: none;
  }
}

// Navbar nav links
//
// Builds on top of the `.nav` components with its own modifier class to make
// the nav the full height of the horizontal nav (above 768px).

.navbar-nav {
  margin: (@navbar-padding-vertical / 2) -@navbar-padding-horizontal;

  >li>a {
    padding-top: 10px;
    padding-bottom: 10px;
    line-height: @line-height-computed;
  }

  @media (max-width: @grid-float-breakpoint-max) {

    // Dropdowns get custom display when collapsed
    .open .dropdown-menu {
      position: static;
      float: none;
      width: auto;
      margin-top: 0;
      background-color: transparent;
      border: 0;
      box-shadow: none;

      >li>a,
      .dropdown-header {
        padding: 5px 15px 5px 25px;
      }

      >li>a {
        line-height: @line-height-computed;

        &:focus,
        &:hover {
          background-image: none;
        }
      }
    }
  }

  // Uncollapse the nav
  @media (min-width: @grid-float-breakpoint) {
    float: left;
    margin: 0;

    >li {
      float: left;

      >a {
        padding-top: @navbar-padding-vertical;
        padding-bottom: @navbar-padding-vertical;
      }
    }
  }
}

// Dropdown menus
// Menu position and menu carets

.navbar-nav>li>.dropdown-menu {
  margin-top: 0;
  .border-top-radius(0);
}

// Menu position and menu caret support for dropups via extra dropup class

.navbar-fixed-bottom .navbar-nav>li>.dropdown-menu {
  margin-bottom: 0;
  .border-top-radius(@navbar-border-radius);
  .border-bottom-radius(0);
}

// Buttons in navbars
//
// Vertically center a button within a navbar (when *not* in a form).

.navbar-btn {
  .navbar-vertical-align(@input-height-base);

  &.btn-sm {
    .navbar-vertical-align(@input-height-small);
  }

  &.btn-xs {
    .navbar-vertical-align(22);
  }
}

// Text in navbars
//
// Add a class to make any element properly align itself vertically within the navbars.

.navbar-text {
  .navbar-vertical-align(@line-height-computed);

  @media (min-width: @grid-float-breakpoint) {
    float: left;
    margin-left: @navbar-padding-horizontal;
    margin-right: @navbar-padding-horizontal;
  }
}

// Component alignment
//
// Repurpose the pull utilities as their own navbar utilities to avoid specificity
// issues with parents and chaining. Only do this when the navbar is uncollapsed
// though so that navbar contents properly stack and align in mobile.
//
// Declared after the navbar components to ensure more specificity on the margins.
@media (min-width: @grid-float-breakpoint) {
  .navbar-left {
    .pull-left();
  }

  .navbar-right {
    .pull-right();
    margin-right: -@navbar-padding-horizontal;

    ~.navbar-right {
      margin-right: 0;
    }
  }
}

// Alternate navbars
// --------------------------------------------------
// Default navbar

.navbar-default {
  background-color: @navbar-default-bg;
  border-color: @navbar-default-border;

  .navbar-brand {
    color: @navbar-default-brand-color;

    &:focus,
    &:hover {
      color: @navbar-default-brand-hover-color;
      background-color: @navbar-default-brand-hover-bg;
    }
  }

  .navbar-text {
    color: @navbar-default-color;
  }

  .navbar-nav {
    >li>a {
      color: @navbar-default-link-color;

      &:focus,
      &:hover {
        color: @navbar-default-link-hover-color;
        background-color: @navbar-default-link-hover-bg;
      }
    }

    >.active>a {

      &,
      &:focus,
      &:hover {
        color: @navbar-default-link-active-color;
        background-color: @navbar-default-link-active-bg;
      }
    }

    >.disabled>a {

      &,
      &:focus,
      &:hover {
        color: @navbar-default-link-disabled-color;
        background-color: @navbar-default-link-disabled-bg;
      }
    }
  }

  .navbar-toggle {
    border-color: @navbar-default-toggle-border-color;

    &:focus,
    &:hover {
      background-color: @navbar-default-toggle-hover-bg;
    }

    .icon-bar {
      background-color: @navbar-default-toggle-icon-bar-bg;
    }
  }

  .navbar-collapse,
  .navbar-form {
    border-color: @navbar-default-border;
  }

  // Dropdown menu items
  .navbar-nav {

    // Remove background color from open dropdown
    >.open>a {

      &,
      &:focus,
      &:hover {
        background-color: @navbar-default-link-active-bg;
        color: @navbar-default-link-active-color;
      }
    }

    @media (max-width: @grid-float-breakpoint-max) {

      // Dropdowns get custom display when collapsed
      .open .dropdown-menu {
        >li>a {
          color: @navbar-default-link-color;

          &:focus,
          &:hover {
            color: @navbar-default-link-hover-color;
            background-color: @navbar-default-link-hover-bg;
          }
        }

        >.active>a {

          &,
          &:focus,
          &:hover {
            color: @navbar-default-link-active-color;
            background-color: @navbar-default-link-active-bg;
          }
        }

        >.disabled>a {

          &,
          &:focus,
          &:hover {
            color: @navbar-default-link-disabled-color;
            background-color: @navbar-default-link-disabled-bg;
          }
        }
      }
    }
  }

  // Links in navbars
  //
  // Add a class to ensure links outside the navbar nav are colored correctly.
  .navbar-link {
    color: @navbar-default-link-color;

    &:hover {
      color: @navbar-default-link-hover-color;
    }
  }

  .btn-link {
    color: @navbar-default-link-color;

    &:focus,
    &:hover {
      color: @navbar-default-link-hover-color;
    }

    &[disabled],
    fieldset[disabled] & {

      &:focus,
      &:hover {
        color: @navbar-default-link-disabled-color;
      }
    }
  }
}

// Inverse navbar

.navbar-inverse {
  background-color: @navbar-inverse-bg;
  border-color: @navbar-inverse-border;

  .navbar-brand {
    color: @navbar-inverse-brand-color;

    &:focus,
    &:hover {
      color: @navbar-inverse-brand-hover-color;
      background-color: @navbar-inverse-brand-hover-bg;
    }
  }

  .navbar-text {
    color: @navbar-inverse-color;
  }

  .navbar-nav {
    >li>a {
      color: @navbar-inverse-link-color;

      &:focus,
      &:hover {
        color: @navbar-inverse-link-hover-color;
        .navbar-item-active-hover;
      }
    }

    >.active>a {

      &,
      &:focus,
      &:hover {
        color: @navbar-inverse-link-active-color;
        .navbar-item-active-hover;
      }
    }

    >.disabled>a {

      &,
      &:focus,
      &:hover {
        color: @navbar-inverse-link-disabled-color;
        background-color: @navbar-inverse-link-disabled-bg;
      }
    }
  }

  // Darken the responsive nav toggle
  .navbar-toggle {
    border-color: @navbar-inverse-toggle-border-color;

    &:focus,
    &:hover {
      background-color: @navbar-inverse-toggle-hover-bg;
    }

    .icon-bar {
      background-color: @navbar-inverse-toggle-icon-bar-bg;
    }
  }

  .navbar-collapse,
  .navbar-form {
    border-color: darken(@navbar-inverse-bg, 7%);
  }

  // Dropdowns
  .navbar-nav {
    >.open>a {

      &,
      &:focus,
      &:hover {
        background-color: @navbar-inverse-link-active-bg;
        color: @navbar-inverse-link-active-color;
      }
    }

    @media (max-width: @grid-float-breakpoint-max) {

      // Dropdowns get custom display
      .open .dropdown-menu {
        >.dropdown-header {
          border-color: @navbar-inverse-border;
        }

        .divider {
          background-color: @navbar-inverse-border;
        }

        >li>a {
          color: @navbar-inverse-link-color;

          &:focus,
          &:hover {
            color: @navbar-inverse-link-hover-color;
            background-color: @navbar-inverse-link-hover-bg;
          }
        }

        >.active>a {

          &,
          &:focus,
          &:hover {
            color: @navbar-inverse-link-active-color;
            background-color: @navbar-inverse-link-active-bg;
          }
        }

        >.disabled>a {

          &,
          &:focus,
          &:hover {
            color: @navbar-inverse-link-disabled-color;
            background-color: @navbar-inverse-link-disabled-bg;
          }
        }
      }
    }
  }

  .navbar-link {
    color: @navbar-inverse-link-color;

    &:hover {
      color: @navbar-inverse-link-hover-color;
    }
  }

  .btn-link {
    color: @navbar-inverse-link-color;

    &:focus,
    &:hover {
      color: @navbar-inverse-link-hover-color;
    }

    &[disabled],
    fieldset[disabled] & {

      &:focus,
      &:hover {
        color: @navbar-inverse-link-disabled-color;
      }
    }
  }
}

/* dropdown */
.navbar-nav {
  ul.dropdown-menu {
    width: 100%;
    padding: 0;
    right: 8px;
  }

  .dropdown-menu>li>a {
    padding: 5px 20px;
  }

  .menu-account {
    margin: 0;
    padding: 0;
    list-style: none;

    >li {
      >a {
        display: block;
        clear: both;
        font-weight: normal;
        line-height: 1.42857143;
        color: #fff;
        white-space: nowrap;
        padding: 5px 20px;

        &:hover,
        &:focus,
        &.active {
          color: #fff;
          background-color: #007bc6;
          text-decoration: none;
        }
      }

      &:last-child {
        a {
          border-bottom-left-radius: 4px;
          border-bottom-right-radius: 4px;
        }
      }
    }
  }

  &.navbar-right {
    .navbar-item {
      display: block;
      height: 100%;
      float: left;

      .region-topbar {
        >.block {
          float: left;
        }

        ul.nav {
          margin: 0;
        }
      }
    }
  }
}


// active, hover status class
.navbar-item-active-hover {
  background-color: #007bc6;
  text-decoration: none;
}

/*
  Navbar Dropdown
*/
.navbar-dropdown {
  //@see color.less [@btn-primary-top]
  border-left: 1px solid @btn-primary-top;
  margin-left: 10px;

  .dropdown-toggle {
    color: #fff;
    display: block;
    padding: 15px 14px;
    line-height: 1;
    position: relative;

    img {
      height: 21px;
      margin: 0;
      width: auto;
    }

    &:hover,
    &:focus {
      .navbar-item-active-hover;
    }
  }

  .dropdown-menu {
    margin-top: 10px;
    min-width: 240px;

    .dropdown-menu-arrow {
      position: absolute;
      display: block;
      width: 0;
      height: 0;
      top: -7px;
      right: 10px;
      margin-left: -7px;
      border-color: transparent;
      border-style: solid;
      border-width: 7px;
      border-top-width: 0;
      border-bottom-color: @brand-primary;
    }

    >li {
      >a {

        &.active,
        &:focus,
        &:hover {
          color: #ffffff;
          background-color: @btn-primary-top;
        }
      }
    }

    .divider {
      background-color: @btn-primary-top;
      margin: 0;
      width: 100%;
    }

    .user {
      padding: 0 20px;

      img {
        width: 56px;
        height: auto;
        display: block;
        margin: 0 auto 10px;
      }

      p {
        color: #ffffff;
        font-size: 12px;
        line-height: 150%;

        &.name {
          font-size: 18px;
        }
      }
    }

    .form-type-select {
      text-align: center;
    }

    // TODO: .lang is front style will remove
    .lang {
      padding: 5px 20px 35px;
      position: relative;
      clear: both;

      h2 {
        font-size: 12px;
        line-height: 1.538em;
        margin: 0;
        color: #ffffff;
        display: block;
        font-weight: normal;
        float: left;
        margin-right: 7px;
      }

      ul {
        background-color: #ffffff;
        left: 84px;
        margin: 0;
        top: 0;
        padding: 0;
        position: absolute;
        border-radius: 5px;
        width: 135px;
        overflow: hidden;

        li {
          list-style: none;
          display: none;

          a {
            display: block;
            font-size: 12px;
            color: #ffffff;
            padding: 3px 14px 3px 7px;
            text-decoration: none;
          }

          &.is-active {
            display: block;

            a {
              background-color: @btn-primary-top;
              text-decoration: none;

              &:before {
                content: '';
                display: inline-block;
                width: 0;
                height: 0;
                margin-left: 2px;
                vertical-align: middle;
                border-top: 4px dashed;
                border-top: 4px solid\9;
                border-right: 4px solid transparent;
                border-left: 4px solid transparent;
                position: absolute;
                right: 4px;
                top: 11px;
              }
            }
          }
        }

        a {

          &:focus,
          &:hover {
            background-color: @btn-primary-top;
            color: #ffffff;
            text-decoration: none;
          }
        }

        &.open {
          li {
            display: block !important;

            &.is-active {
              a {
                &:before {
                  border-top: none;
                  border-bottom: 4px dashed;
                  border-bottom: 4px solid\9;
                  border-right: 4px solid transparent;
                  border-left: 4px solid transparent;
                }
              }
            }
          }
        }
      }
    }
  }

  .open {
    .dropdown-toggle {
      // @see color.less
      background-color: @btn-primary-top  !important;

      &:focus,
      &:hover {
        text-decoration: none;
      }
    }
  }

  @media (max-width: 767px) {
    .dropdown-menu {
      position: static;
      display: block;
    }

    .dropdown-toggle {
      display: none;
    }

    .dropdown-menu .user {
      padding-top: 0;
    }

    .dropdown-menu .lang {
      width: 225px;
      margin: 0 auto;
    }
  }

  #user-dropdown+ul.dropdown-menu {
    .lang {
      padding-bottom: 48px;

      ul {
        margin: 0 auto;
        left: 0;
        right: 0;

        a {
          background-color: #007bc6;

          &:hover {
            color: #333;
          }
        }
      }
    }
  }
}

.topbar {
  backface-visibility: hidden;
  position: fixed;
  top: 0;
  right: 0;
  left: 0;
  box-shadow: 0 0 2px #979797;
  z-index: 1000;
  background-color: #fff;
  border-bottom: 1px solid rgba(255, 255, 255, 0.2);

  .lang {
    list-style: none;

    @media screen and (max-width: 768px) {
      padding-right: 22px;
    }

    >ul {
      position: relative;
      float: right;
      list-style: none;
      margin-top: 10px;

      .dropdown-menu {
        top: 24px;
        right: 0;
        left: unset;
        background: #fff;
        box-shadow: 0 2px 12px rgba(0, 0, 0, 0.2);

        a {
          display: block;

          &:hover {
            background: #5bc0de;
            color: #fff;
          }
        }
      }

      a {
        padding-right: 20px;
        color: #66757f;
        display: none;
        font-size: 13px;

        &.is-active {
          position: relative;
          display: block;

          &:before {
            content: '';
            display: inline-block;
            width: 0;
            height: 0;
            margin-left: 2px;
            vertical-align: middle;
            border-top: 4px dashed;
            border-top: 4px solid\9;
            border-right: 4px solid transparent;
            border-left: 4px solid transparent;
            position: absolute;
            right: 0;
            top: 8px;
          }
        }
      }
    }
  }
}

.navbar-inverse {
  background-image: linear-gradient(to bottom, #055a8e 0%, #1d84c3 100%);
}
